<template>
  <el-dialog title="查看管理员" :visible.sync="formVisible">
    <el-form ref="dataForm" :model="form"
             label-position="left" size="small"
             label-width="100px" style="width: 400px; margin-left:50px;">
      <el-form-item label="主键">
        <span class="form-item-show">
          {{ form.id }}
        </span>
      </el-form-item>
      <el-form-item label="用户名">
        <span class="form-item-show">
          {{ form.username }}
        </span>
      </el-form-item>
      <el-form-item label="密码">
        <span class="form-item-show">
          {{ form.password }}
        </span>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="formVisible = false">
        取消
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
import adminApi from '@/api/admin/admin'

export default {
  name: 'AdminShow',
  data() {
    return {
      form: {
        id: null,
        username: null,
        password: null
      },
      formVisible: false
    }
  },
  methods: {
    /**
     * 打开查看表单
     */
    handleShow(id) {
      adminApi.fetchById(id)
        .then(data => {
          this.form = data
          this.formVisible = true
        })
    }
  }
}
</script>
